package Controls
{
	import Tools.BitmapTool;
	import Tools.DisplayTool;
	
	import flash.display.BitmapData;

	public class HSlider extends Slider
	{
		public function HSlider()
		{
			super();
		}
		override public function get percent():Number
		{
			return slider.obj.x/dragRect.width;
		}
		override public function set percent(value:Number):void
		{
			slider.obj.x=dragRect.width*value;
		}
		override protected function syncFull(_percent:Number):void
		{
			var imageData:BitmapData;
			var width:int=fullImage.width*_percent;
			if(width>0)
			{
				imageData=BitmapTool.scale(fullImage,width,fullImage.height);
			}
			full.setImage(imageData);
		}
		override public function setup(width:Number,height:Number,border:int=1):void
		{
			track.scale(width,height);
			
			full.scale(width-border*2,height-border*2);
			full.obj.x=border;
			full.obj.y=border;
			fullImage=full.bitmap.bitmapData;
			syncFull(0);
			
			slider.moveTo(0,track.obj.height/2,0,0.5);
			
			dragRect.x=0;
			dragRect.y=slider.obj.y;
			dragRect.width=width-slider.obj.width;
			dragRect.height=0;
		}
	}
}